"use strict";

exports.__esModule = true;
exports.default = void 0;

var _utils = require("../utils");

var _relation = require("../mixins/relation");

var _constant = require("../utils/constant");

var _createNamespace = (0, _utils.createNamespace)('tabbar'),
    createComponent = _createNamespace[0],
    bem = _createNamespace[1];

var _default = createComponent({
    mixins: [(0, _relation.ParentMixin)('vanTabbar')],
    props: {
        route: Boolean,
        activeColor: String,
        inactiveColor: String,
        safeAreaInsetBottom: Boolean,
        value: {
            type: [Number, String],
            default: 0
        },
        border: {
            type: Boolean,
            default: true
        },
        fixed: {
            type: Boolean,
            default: true
        },
        zIndex: {
            type: Number,
            default: 1
        }
    },
    watch: {
        value: 'setActiveItem',
        children: 'setActiveItem'
    },
    methods: {
        setActiveItem: function setActiveItem() {
            var _this = this;

            this.children.forEach(function (item, index) {
                item.active = (item.name || index) === _this.value;
            });
        },
        onChange: function onChange(active) {
            if (active !== this.value) {
                this.$emit('input', active);
                this.$emit('change', active);
            }
        }
    },
    render: function render() {
        var _ref;

        var h = arguments[0];
        return h("div", {
            "style": {
                zIndex: this.zIndex
            },
            "class": [(_ref = {}, _ref[_constant.BORDER_TOP_BOTTOM] = this.border, _ref), bem({
                fixed: this.fixed,
                'safe-area-inset-bottom': this.safeAreaInsetBottom
            })]
        }, [this.slots()]);
    }
});

exports.default = _default;